package Data;

import java.util.ArrayList;


public class VipDataStore implements ObjectTableInterface{
	private DataWriterInterface vipWriter;
	private DataReaderInterface vipReader;
	ArrayList<Vip> vip;
	
	

	public VipDataStore(DataWriterInterface vipWriter,DataReaderInterface vipReader) {
		super();
//		this.vipWriter = new VipDataWriter();
//		this.vipReader = new VipDataReader();
		this.vipWriter = vipWriter;
		this.vipReader = vipReader;
		initializeData();
		
	}
	
	public void initializeData(){
//		System.out.println(((Vip)vipReader.getRecordByID(1000)));
		vip = new ArrayList<Vip>();
		ArrayList<String> s = vipReader.readrecord();
		for(int i=0;i<s.size();i++){
			addVip(s.get(i));
		}
		System.out.println("initializeData");
	}
	public ArrayList<String> showVip(){
		return vipReader.readrecord();
		
	}
//	public ArrayList<Vip> showVipInObject(){
//		ArrayList<>
//	}
	public Vip findVipByID(int ID){
		Vip v =null;
		for(int i=0;i<vip.size();i++){
			if(ID==vip.get(i).getID()){
				v=vip.get(i);
				break;
			}
		}
//		Vip v = (Vip)vipReader.getRecordByID(ID);
//		if(v!=null){
//			s = v.toString();
//		}
		return v;
	}

	
	public void addVip(String vipData){
		Vip one = (Vip)Vip.toObject(vipData);
		vip.add(one);
	}
	public void addVip(Vip v){
		vip.add(v);
	}
//	public void addNewVip(String vipData){
//	
//		Vip newone = (Vip)Vip.toObject(vipData);
//		vip.add(newone);
//	}


	@Override
	public Object[][] getObjetTable() {
		// TODO Auto-generated method stub
		Object [][] object = new Object[vip.size()][8];
		for(int i=0;i<vip.size();i++){
			object[i] = vip.get(i).toString().split(",");
			
		}
		
		return object;
	}

}
